<template>
	<view class="scrool-page">
		<view class="list-cont">
			<scroll-view class="scrool-more" style="height: 100%" scroll-y="true" scroll-with-animation="true">
				<view v-for="(item,index) in detailList" :key="index">
					<uni-card v-if="item.itemCode != null">
						<view style="display: flex; align-items: center; justify-content: space-between;">
							<view>
								<view class="uni-body">物料编码：{{ item.itemCode }}</view>
								<view class="uni-body">物料名称：{{ item.itemName }}</view>
							</view>
							<input v-if="docType == '0'" :disabled="item.boxCountShow"
								style="border: 1px solid #e6e6e6; width: 100px; height: 45px;" v-model="item.Count"
								@blur="validateInput(index,item.boxCount)" placeholder="请输入数量"></input>
							<input v-else style="border: 1px solid #e6e6e6; width: 100px; height: 45px;"
								v-model="item.boxCount" :disabled="item.boxCountShow ==true?true:false"
								@blur="validateInput(index,item.boxCount)" placeholder="请输入数量"></input>
						</view>

						<!-- <text class="uni-body">物料编码：{{ item.itemCode }}</text><br>
						<text class="uni-body">物料名称：{{ item.batchNumber }}</text><br> -->
						<!-- <text class="uni-body">数量：</text>			
						<uni-number-box v-model="item.qtyCheck"></uni-number-box><br> -->
					</uni-card>
				</view>
			</scroll-view>
		</view>

		<view class="footer">
			<button type="default" size='mini' style="width:48%; margin-left:1%;" @click="addData">提交</button>
			<button type="default" size='mini' style="width:48%; margin-left:1%;" @click="reduceData">扫码盘点</button>
			<!-- <button type="default" size='mini' style="width:32%; margin-left:1%;" @click="submit">完成</button> -->
		</view>

		<uni-popup ref="alertDialog" type="dialog" :is-mask-click="false">
			<uni-popup-dialog type="success" cancelText="关闭" confirmText="确定" title="提示" :before-close="true"
				:content="content" @confirm="dialogConfirm" @close="dialogClose">
			</uni-popup-dialog>
		</uni-popup>
	</view>
</template>

<script>
	import {
		debounce
	} from '@/api/system/Tool.js'
	import {
		LocationDetails
	} from '@/api/system/interfaceFile.js'
	import {
		getToken
	} from '@/utils/auth';
	import common from '../../pages/common/common.js'
	var main, receiver, filter;
	var ScanDeviceClass = plus.android.importClass("android.device.ScanDevice");
	var scanDevice;
	export default {
		data() {
			return {
				shouldCheck: true,
				productListData: [],
				pagesData: null,
				detailListOld: [],
				detailList: [],
				detailListNewData: [],
				content: '物料账实不符，请重新扫箱码',
				baseUrl: getApp().globalData.config.baseUrl,
				userName: this.$store.state.user.name,
				orgId: getApp().globalData.config.orgId,
				itemCodeException: [],
				boxCodeException: [],
				storageLocation: '',
				userFlag: 0,
				batchNumber: '',
				pkOrder: '',
				lineId: '',
				areaId: '',
				id: '',
				status: '',
				itemIds: null, //领取计划 ID
				docType: null, //明盘 暗盘
				exceptionList: [],
				inputIndex: 0,
				areQuantitiesEqual: false,
				tasktype: '',
				NoStorageSpaceAvailable: [],
				ScanCodeData: null,
				dataList: '', //复盘使用的数据
			}
		},

		onLoad: function(option) {
			console.log('1231313131',option.tasktype)
			if (option.tasktype == '初盘') {
				uni.setStorageSync('shouldCheck', true)
			}

			this.pagesData = getCurrentPages();

			this.orgId = uni.getStorageSync('orgId');
			this.storageLocation = uni.getStorageSync('storageLocation');;
			this.docType = option.docType
			this.batchNumber = option.batchNumber;
			this.pkOrder = option.pkOrder;

			this.lineId = option.lineId;
			this.areaId = option.areaId;
			this.id = option.id;
			this.status = option.status;
			this.tasktype = option.tasktype
			console.log('option.dataList', option.dataList)
			this.dataList = option.dataList

			if (option.dataList) {
				this.dataList = JSON.parse(option.dataList)
			}

			this.itemIds = option.itemIds

			// if(this.status == '2'){
			// 	uni.setNavigationBarTitle({
			// 		title:this.storageLocation+'货位(已完成)'
			// 	});
			// }else{
			// 	uni.setNavigationBarTitle({
			// 		title:this.storageLocation+'货位(未完成)'
			// 	});
			// }

			let pages = getCurrentPages();
			let prevPage = pages[pages.length - 2]
			console.log(prevPage, prevPage.$vm.detailList)
			uni.setNavigationBarTitle({
				title: this.storageLocation + '货位'
			});
		},

		//返回上一页
		onBackPress(options) {
			if (options.from === 'navigateBack') {
				return false;
			}
			//this.unregisterScan();
			let pages = getCurrentPages(); //获取所有页面栈实例列表
			let nowPage = pages[pages.length - 1]; //当前页页面实例
			let prevPage = pages[pages.length - 2]; //上一页页面实例
			uni.navigateBack({ //uni.navigateTo跳转的返回，默认1为返回上一级
				delta: 1
			});
			return true;
		},
		//       onUnload(){
		// 	uni.setStorageSync('ScanCodeData','')
		// },
		onShow() {
			this.$refs.alertDialog.close();
			// scanDevice = new ScanDeviceClass();
			// scanDevice.openScan(); // 打开扫描
			// scanDevice.setOutScanMode(0); // 扫描模式				
			// this.initScan();
			// this.registerScan();
			this.ScanCodeData = uni.getStorageSync('ScanCodeData')

			console.log(this.ScanCodeData, '	this.ScanCodeData’')
			if (this.ScanCodeData != '') {
				this.shouldCheck = false
				this.detailListNewData = []
				let arr = this.ScanCodeData
				console.log(arr, 'arr')
				let arrData = []
				// this.detailList
				const groupedItems = arr.reduce((acc, curr) => {
					if (!acc[curr.itemCode]) {
						acc[curr.itemCode] = [];
					}
					acc[curr.itemCode].push(curr);
					// 返回累积器，以便下一次迭代  
					return acc;
				}, {});
				const result = Object.entries(groupedItems).map(([itemCode, values]) => ({
					itemCode, // 直接使用键作为 itemCode  
					items: values // 使用值作为具有相同 itemCode 的对象数组  
				}));

				arrData = result.map((item) => {
					let obj = item.items[0]
					return {
						...obj,
						Count: item.items.length,
						list: [],
						boxCountShow: true
					}
				})
				let ListData = uni.getStorageSync('list')

				let arrListData = ListData
				this.detailListNewData = arrData
				this.detailListNewData.forEach(item => {
					arrListData.forEach(i => {
						if (item.itemCode == i.itemCode) {
							item.list.push(i)
						}
					})
				})
				console.log('this.detailListNewData', this.detailListNewData)
				console.log('this.detailList', this.detailList)
				let dataLISTData = []
				if (this.detailList.length > 0) {
					this.detailList.forEach(item2 => {

						let exists = this.detailListNewData.some(item3 => item3.itemCode == item2.itemCode)
						console.log('exists', exists)
						if (!exists) {
							dataLISTData.push(item2)
						}
					})
					if (dataLISTData.length > 0) {
						this.detailListNewData.push(...dataLISTData)
					}


					this.detailList = this.detailListNewData
				} else {
					this.detailList = this.detailListNewData
				}


				console.log('this.detailList', this.detailList)
				this.areQuantitiesEqual = true

			} else {

				if (this.tasktype != '复盘') {
					this.shouldCheck = true
				}


			}
			if (this.tasktype == '复盘') {
				console.log('this.dataList', this.dataList)

			}


			if (uni.getStorageSync('shouldCheck') == false && this.ScanCodeData == '') {
				this.areQuantitiesEqual = true
				this.detailList = this.detailList.map(item => {
					let obj = item
					obj.Count = 0
					return {
						...obj,

						boxCountShow: true
					}
				})
			}





			uni.setStorageSync('ScanCodeData', '')

		},

		created() {




			this.query(this.storageLocation);
		},
		onUnload() {
			this.$refs.alertDialog.close();
		},
		onHide: function() {
			// this.unregisterScan();
			this.$refs.alertDialog.close();
		},

		destroyed: function() {
			this.$refs.alertDialog.close();
			// this.unregisterScan();
		},

		methods: {
			replacer(key, value) {
				// 如果 value 是对象并且包含当前对象（即循环引用）  
				// 则返回 undefined（或者其他你想要的值），这样它就不会被包含在结果中  
				if (typeof value === 'object' && value !== null) {
					if (value.__circular) {
						return; // 或者返回 undefined, null, 或其他你想要的占位符  
					}
					// 为了防止进一步的循环引用，我们标记这个对象为已访问  
					value.__circular = true;
				}
				return value;
			},
			initScan() {
				return
				let _this = this;
				main = plus.android.runtimeMainActivity(); //获取activity  
				var IntentFilter = plus.android.importClass('android.content.IntentFilter');
				filter = new IntentFilter();
				filter.addAction("scan.rcv.message"); // 换你的广播动作  
				receiver = plus.android.implements('io.dcloud.feature.internal.reflect.BroadcastReceiver', {
					onReceive: function(context, intent) {
						plus.android.importClass(intent);
						let code = intent.getByteArrayExtra('barocode');
						let codeStr = common.utf8ByteToUnicodeStr(code);
						scanDevice.stopScan(); // 停止扫描	
						_this.buttonScan(codeStr);
					}
				});
			},

			query() {
				uni.showLoading({
					title: '加载中',
					mask: true
				});
				var that = this;



				if (this.storageLocation == undefined) {
					this.storageLocation = uni.getStorageSync('storageLocation', )
				}
				if (this.pkOrder == undefined) {
					this.pkOrder = uni.getStorageSync('pkOrder')
				}
				console.log('搜索', this.storageLocation, this.itemIds, this.pkOrder)
				uni.request({
					url: that.baseUrl + '/system/WmsCheckOrder/getBoxNumByAreaCode',
					data: {
						areaCode: this.storageLocation,
						itemIds: this.itemIds,
						pkOrder: this.pkOrder

					},
					method: 'POST',
					header: {
						'authorization': getToken()
					},
					dataType: 'json',
					success: (res) => {
						//隐藏加载框
						uni.hideLoading();
						uni.showToast({
							title: res.data.msg,
							icon: 'none',
							duration: 2000
						});
						console.log('query', res.data);
						if (res.data.code == '200' || res.data.code == 200) {
							let id = []
							res.data.data.forEach(i => {
								if (i.itemId) {
									id.push(i.itemId)
								}
							})


							console.log('console.log(this.itemIds)', this.itemIds, id)
							this.itemIds = id.toString()
							console.log(this.itemIds)
							// this.detailListOld = res.data.data
							uni.setStorageSync('detailListOld', res.data.data);
							this.NoStorageSpaceAvailable = []
							res.data.data.forEach(item => {
								this.NoStorageSpaceAvailable.push(item.itemId)
							})

                            let tasktype = this.tasktype
							if (tasktype == undefined) {
								tasktype = uni.getStorageSync('tasktype')
							}
							console.log(this.dataList)
							console.log('this.tasktype', tasktype,uni.getStorageSync('tasktype'))
							console.log('this.detailList', this.detailList)

							if (tasktype == '复盘') {
								this.docType = '0'
								if (this.dataList != '') {
									let dataLISTData = []
									this.detailList = res.data.data
									
									
									
									this.detailList.forEach(item2 => {

										let exists = this.dataList.some(item3 => item3
											.itemCode == item2.itemCode)
										console.log('exists', exists)
										if (!exists) {
											dataLISTData.push(item2)
										}
									})
									if (dataLISTData.length > 0) {
										this.dataList.push(...dataLISTData)
									}

       
									this.detailList = this.dataList.map(item => {
										let nub = 0 
										if(item.list){
											nub = item.list.length
										}
										return {
											...item,
											Count: nub,
											boxCountShow: true
										}
									})

     	                         

									console.log('this.detailList', this.detailList)
								} else {

									this.detailList = res.data.data.map(item => {
										return {
											...item,
											Count: 0,
											boxCountShow: true
										}
									})
									console.log('this.detailList复盘', this.detailList)
								}




							} else {
								this.detailList = res.data.data.map(item => {
									return {
										...item,
										Count: 0,
										boxCountShow: false
									}
								})
							}



						} else {
							uni.showToast({
								title: res.data.msg,
								icon: 'none',
								duration: 5000
							});
							return;
						}

					},
					fail(err) {
						uni.hideLoading();
						uni.showToast({
							title: err,
							icon: 'none',
							duration: 5000
						});
					}
				})
			},
			validateInput(index, boxCount) {
				this.inputIndex = index
				console.log(index)
				// console.log(uni.getStorageSync('detailListOld'))
				// console.log(this.detailList)
				const item = uni.getStorageSync('detailListOld')[index];
				const items = this.detailList[index];





				if (this.docType == '0') {
					if (parseInt(items.Count) != boxCount) {
						this.content = item.itemCode + '物料账实不符，请重新扫箱码';
						this.$refs.alertDialog.open();
						this.areQuantitiesEqual = false
					}

				} else {
					if (Number(items.boxCount) !== Number(item.boxCount)) {
						this.content = item.itemCode + '物料账实不符，请重新扫箱码';
						this.$refs.alertDialog.open();
						this.areQuantitiesEqual = false
					}
				}


			},

			registerScan() {
				main.registerReceiver(receiver, filter);
			},

			unregisterScan() {
				main.unregisterReceiver(receiver);
			},

			submit() {
				//显示加载框
				uni.showLoading({
					title: '加载中',
					mask: true
				});
				var that = this;
				if (that.status == '2') {
					uni.showToast({
						title: '此批次的物料已经盘点完成',
						icon: 'none',
						duration: 5000
					});
					return;
				}

				that.itemCodeException = [];
				for (var i = 0; i < that.detailList.length; i++) {
					var data = that.detailList[i];
					if (data.qtyCheck != data.num && !data.isAdd && data.handleFlag != 'true') {
						that.itemCodeException.push(data);
						break;
					}
				}
				if (that.itemCodeException.length == 0) {
					//隐藏加载框
					uni.hideLoading();
					if (that.boxCodeException.length > 0) {
						that.exceptionHand();
					} else {
						that.successData();
					}
				} else {
					//隐藏加载框
					uni.hideLoading();
					that.content = that.itemCodeException[0].itemCode + '物料账实不符，请重新扫箱码';
					that.itemCode = data.itemCode;
					that.$refs.alertDialog.open();
				}
			},

			exceptionHand() {
				//显示加载框
				uni.showLoading({
					title: '加载中',
					mask: true
				});
				var that = this;
				uni.request({
					url: that.baseUrl + '/system/WmsCheckOrder/checkLine/reportCheckLineError',
					data: {
						checkOrderId: that.pkOrder,
						orgId: that.orgId,
						areaId: that.areaId, //单据数据库主键id
						detailList: that.boxCodeException,
						userName: that.userName
					},
					method: 'POST',
					header: {
						'authorization': getToken()
					},
					dataType: 'json',
					success: (res) => {
						console.log(res)
						var code = res.data.code;
						if (code == '200') {
							that.successData();
							//隐藏加载框
							uni.hideLoading();
						} else {
							//隐藏加载框
							uni.hideLoading();
							uni.showToast({
								title: res.data.msg,
								icon: 'none',
								duration: 3000
							});
							return;
						}
					}
				})
			},

			successData() {
				//显示加载框
				uni.showLoading({
					title: '加载中',
					mask: true
				});
				var that = this;
				var tempList = []
				if (that.boxCodeException.length > 0) {
					for (var i = 0; i < that.detailList.length; i++) {
						if (!that.detailList[i].handleFlag) {
							tempList.push(that.detailList[i]);
						}
					}
				} else {
					tempList = that.detailList;
				}
				if (tempList.length == 0) {
					//隐藏加载框
					uni.hideLoading();
					uni.showToast({
						title: '操作成功',
						icon: 'none',
						duration: 5000
					});
					return;
				}


				uni.request({
					url: that.baseUrl + '/system/WmsCheckOrder/checkLine/reportCheckLineTrueAndFalse',
					data: {
						orgId: that.orgId,
						userName: that.userName,
						pkOrder: that.pkOrder,
						successList: tempList,
						exceptionList: that.exceptionList
					},
					method: 'POST',
					header: {
						'authorization': getToken()
					},
					dataType: 'json',
					success: (res) => {

						if (code == '200') {
							uni.hideLoading();
							uni.showToast({
								title: '操作成功',
								icon: 'none',
								duration: 3000
							});

							let pages = getCurrentPages(); //获取所有页面栈实例列表
							let nowPage = pages[pages.length - 1]; //当前页页面实例
							let prevPage = pages[pages.length - 2]; //上一页页面实例

							prevPage.$vm.query();

							setTimeout(function() {
								uni.navigateBack({ //uni.navigateTo跳转的返回，默认1为返回上一级
									delta: 1
								});
							}, 1000);
						} else {
							//隐藏加载框
							uni.hideLoading();
							uni.showToast({
								title: res.data.msg,
								icon: 'none',
								duration: 5000
							});
							return;
						}

					},
				})


				// uni.request({
				// 	url: that.baseUrl + '/system/WmsCheckOrder/checkLine/reportCheckLine',
				// 	data: {
				// 		checkOrderId: that.pkOrder,
				// 		orgId: that.orgId,
				// 		areaId: that.areaId, //单据数据库主键id
				// 		detailList: tempList,
				// 		userName: that.userName,
				// 		//lineId:that.lineId
				// 	},
				// 	method: 'POST',
				// 	header: {
				// 		'authorization': getToken()
				// 	},
				// 	dataType: 'json',
				// 	success: (res) => {
				// 		console.log(res)
				// 		var code = res.data.code;
				// 		if (code == '200') {
				// 			//隐藏加载框
				// 			uni.hideLoading();
				// 			uni.showToast({
				// 				title: '操作成功',
				// 				icon: 'none',
				// 				duration: 3000
				// 			});
				// 			let pages = getCurrentPages(); //获取所有页面栈实例列表
				// 			let nowPage = pages[pages.length - 1]; //当前页页面实例
				// 			let prevPage = pages[pages.length - 2]; //上一页页面实例
				// 			prevPage.$vm.query();
				// 			//that.unregisterScan();					
				// 			setTimeout(function() {
				// 				uni.navigateBack({ //uni.navigateTo跳转的返回，默认1为返回上一级
				// 					delta: 1
				// 				});
				// 			}, 1000);
				// 		} else {
				// 			//隐藏加载框
				// 			uni.hideLoading();
				// 			uni.showToast({
				// 				title: res.data.msg,
				// 				icon: 'none',
				// 				duration: 5000
				// 			});
				// 			return;
				// 		}
				// 	}
				// })
			},

			dialogConfirm() {
				//显示加载框
				// uni.showLoading({
				// 	title: '加载中',
				// 	mask: true
				// });
				var that = this;

				// let pages = getCurrentPages(); //获取所有页面栈实例列表
				// let nowPage = pages[pages.length - 1]; //当前页页面实例
				// let prevPage = pages[pages.length - 2]; //上一页页面实例
				// for (var i = 0; i < prevPage.$vm.productList.length; i++) {
				// 	if (prevPage.$vm.productList[i].storageLocation == this.storageLocation) {
				// 		prevPage.$vm.productList[i].flag = false;
				// 		break;
				// 	}
				// }
				// var list = encodeURIComponent(JSON.stringify(that.boxCodeException));
				// var data = that.itemCodeException[0];
				// uni.navigateTo({
				// 	url: '/pages/special/wms_check_order_item_detaile?storageLocation=' + that.storageLocation +
				// 		"&batchNumber=" + that.batchNumber + "&id=" + that.id +
				// 		"&lineId=" + that.lineId + "&list=" + list + "&numOld=" + data.num + "&itemCodeOld=" + data
				// 		.itemCode,
				// })




				uni.navigateTo({
					url: '/pages/special/wms_check_order_item_detaile?storageLocation=' + this.storageLocation +
						'&itemIds=' + this.itemIds +
						"&batchNumber=" + this.detailList[this.inputIndex].boxCount + '&tasktype=' + this
						.tasktype + '&NoStorageSpaceAvailable=' + this.NoStorageSpaceAvailable,
					success: function() {

						this.$refs.alertDialog.close();
					}

				})


				//隐藏加载框
				// uni.hideLoading();

			},

			dialogClose() {
				this.$refs.alertDialog.close();
			},




			addData() {
				console.log('detailList', this.detailList)
				// const shouldCheck  = uni.getStorageSync('boole')
				// console.log(boole, 'boole',this.detailList)
				console.log(uni.getStorageSync('shouldCheck'), '123132')


				if (this.shouldCheck && this.detailList.length > 0 && uni.getStorageSync('shouldCheck') != false) {

					if (!this.detailList.every(item => item.boxCount == item.Count)) {
						uni.showToast({
							title: '请填写正确的物料数量',
							icon: 'none',
							duration: 2000
						});
						return


					}
				}








				debounce(() => {
					let params = {
						orgId: this.orgId,
						userName: this.userName,
						pkOrder: this.pkOrder,
						areaId: this.areaId,
						areaCode: this.storageLocation,
						successList: null,
						exceptionList: null
					}

					console.log(this.tasktype, '---', this.dataList)
					if (this.tasktype == undefined) {
						this.tasktype = uni.getStorageSync('tasktype')
					}
					if (this.tasktype == '复盘') {
						if (this.dataList) {
							params.exceptionList = this.dataList

						} else {
							params.exceptionList = this.detailList
						}


					} else {
						this.detailList.forEach(item => {
							item.areaCode = this.storageLocation
						})



						if (this.areQuantitiesEqual) {
							params.exceptionList = this.detailList
						} else {
							params.successList = this.detailList
						}
					}



					// let str = JSON.stringify(params)
					// uni.showToast({
					// 	duration: 10000,
					// 	title:  `${str}`,
					// 	icon: 'none'
					// })


					console.log('params', params, this.areQuantitiesEqual, this.tasktype)
					LocationDetails('/system/WmsCheckOrder/checkLine/newReportCheckLineTrueAndFalse', params).then(
						res => {
							uni.showToast({
								duration: 2000,
								title: `${res.msg}`,
								icon: 'none'
							})
							if (this.tasktype == '复盘') {
								uni.navigateTo({
									url: `/pages/special/wms_check_order?status=${0}`
								})

							} else {
								uni.navigateBack({ //uni.navigateTo跳转的返回，默认1为返回上一级
									delta: 1
								});
							}





						}).catch(err => {
						uni.showToast({
							duration: 2000,
							title: `${err}`,
							icon: 'none'
						})
						uni.navigateBack({ //uni.navigateTo跳转的返回，默认1为返回上一级
							delta: 1
						});
						console.log(err, 'err')
					})
					uni.setStorageSync('boole', true)



				}, 1000)

				// if (this.areQuantitiesEqual == false) {
				// 	uni.showToast({
				// 		duration: 4000,
				// 		title: '输入的数量与查询的数量不符，不允许暂存，请全盘扫描',
				// 		icon: 'none'
				// 	})
				// } else {

				// 	//获取所有页面栈实例列表
				// 	// let nowPage = pages[pages.length - 1]; //当前页页面实例
				// 	let prevPage = this.pagesData[this.pagesData.length - 2]; //上一页页面实例

				// 	var detailList = prevPage.$vm.productList;



				// 	var qtyCheck = 0;
				// 	var boxCount = 0;
				// 	for (var i = 0; i < detailList.length; i++) {
				// 		if (detailList[i].areaCode == this.storageLocation) {
				// 			//detailList[i].qtyCheck = that.productList.length;
				// 			qtyCheck = detailList[i].qtyCheck;
				// 			boxCount = detailList[i].boxCount;
				// 			detailList[i].attr9 = "2";
				// 			break;
				// 		}
				// 	}
				// 	let json = JSON.stringify(this.productListData)
				// 	uni.setStorageSync('ScanCodeData', json)
				// 	uni.navigateBack({
				// 		delta: 1
				// 	});
				// 	// setTimeout(function() {
				// 	// 	uni.navigateBack({ //uni.navigateTo跳转的返回，默认1为返回上一级
				// 	// 		delta: 1
				// 	// 	});
				// 	// }, 1000);
				// }


			},

			reduceData() {
				this.userFlag = 2;

				let NUMBER = ''
				if (this.detailList[this.inputIndex]) {
					NUMBER = this.detailList[this.inputIndex].boxCount
				}

				let detailList = JSON.stringify(this.detailList)
				console.log(detailList, ' this.detailList')
				uni.navigateTo({
					url: '/pages/special/wms_check_order_item_detaile?storageLocation=' + this.storageLocation +
						'&itemIds=' + this.itemIds +
						"&batchNumber=" + NUMBER + '&tasktype=' + this
						.tasktype + '&NoStorageSpaceAvailable=' + this.NoStorageSpaceAvailable + '&detailList=' +
						detailList
				})
			},

			// 扫描查询
			buttonScan(codeStr) {
				//显示加载框
				uni.showLoading({
					title: '加载中',
					mask: true
				});
				var result = common.scanCode(codeStr);
				if (this.userFlag == 1 || this.userFlag == '1') {
					if (result[0] != 'P') {
						//隐藏加载框
						uni.hideLoading();
						uni.showToast({
							title: '请扫描物料编码',
							icon: 'none',
							duration: 2000
						});
					} else {
						var flag = false;
						for (var i = 0; i < this.detailList.length; i++) {
							if (this.detailList[i].itemCode == result[1]) {
								flag = true;
								break;
							}
						}
						if (flag) {
							//隐藏加载框
							uni.hideLoading();
							uni.showToast({
								title: '此数据已存在，请填写盘点数量',
								icon: 'none',
								duration: 2000
							});
						} else {
							var arr = {
								itemCode: result[1],
								qtyCheck: 0,
								inputNumber: 0,
								isAdd: true
							};
							this.detailList.push(arr);
						}
					}
				} else if (this.userFlag == 2 || this.userFlag == '2') {
					if (result[0] != 'P') {
						//隐藏加载框
						uni.hideLoading();
						uni.showToast({
							title: '请扫描物料编码',
							icon: 'none',
							duration: 2000
						});
					} else {
						var tempList = [];
						for (var i = 0; i < this.detailList.length; i++) {
							if (this.detailList[i].itemCode != result[1]) {
								tempList.push(this.detailList[i]);
							}
						}
						if (tempList.length == this.detailList.length) {
							//隐藏加载框
							uni.hideLoading();
							uni.showToast({
								title: '此数据不存在',
								icon: 'none',
								duration: 2000
							});
						} else {
							this.detailList = tempList;
							//隐藏加载框
							uni.hideLoading();
						}
					}
				}
			}
		}
	}
</script>

<style lang="scss">
	.main {
		background-color: #fff;
		height: 300upx;
		align-items: center;
		margin-top: 10upx;
	}

	.text-content {
		font-size: 48rpx;
		text-align: center;
	}

	.city {
		/* #ifndef APP-PLUS-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		align-items: center;
		justify-content: flex-start;
		// width: 160rpx;
		margin-left: 4px;
		font-size: 26rpx;
	}

	.input-view {
		display: flex;
		flex-direction: row;
		flex: 1;
		//background-color: #f8f8f8;
		height: 30px;
		padding: 0 80px;
		flex-wrap: nowrap;
		margin: 7px 0;
		line-height: 30px;
		font-size: 26rpx;
	}

	page {
		width: 100%;
		height: 100%;
	}


	.scrool-page {
		display: flex;
		flex-direction: column;
		width: 100%;
		height: 100%;
	}

	.header-cont {
		width: 100%;
		height: 110rpx;
		line-height: 100rpx;
		text-align: center;
		// background: red;
	}

	.list-cont {
		flex: 1;
		position: relative;

		.scrool-more {
			position: absolute;
			left: 0;
			right: 0;
			top: 0;
			bottom: 0;
		}

		.list {
			height: 80rpx;
			line-height: 80rpx;
			text-align: center;
			background: #e0e0e0;

		}
	}


	.footer {
		color: #fff;
		line-height: 100rpx;
		flex: 0 0 100rpx;
		/* 不放大不缩小固定100rpx */
	}
</style>